#-*- coding: utf-8 -*-

import subprocess
import sys
 
class FlushFile(object):
    """Write-only flushing wrapper for file-type objects."""
    def __init__(self, f):
        self.f = f
    def write(self, x):
        self.f.write(x)
        self.f.flush()
 
sys.stdout = FlushFile(sys.__stdout__)

popen = subprocess.Popen(['P:/Work/EPP/ZT598/ZT598S/ZT598_Sxx_C70固件下载/lib/serial_sender.exe', '-sCOM6', '-t', '2', '-v', 'P:/Work/EPP/ZT598/ZT598S/ZT598_Sxx_C70固件下载/固件/IAP/ZT-FW-598-Sxx-C70-IAP-V1001/packet.list'], stdout = subprocess.PIPE)
#popen = subprocess.Popen(['ping', 'www.baidu.com', '-n', '3'], stdout = subprocess.PIPE)
 
 
while True:
    next_line = popen.stdout.readline()
    if next_line == '' and popen.poll() != None:
        break
    sys.stdout.write(next_line)
